<template>
  <el-empty v-if="vjsonReloadMark" :description="locale.runtime.layoutLoading"/>
  <component v-else
             :is="getLayoutCmp(vjson.layoutTag)"
             :vjson="vjson"
             :vcxt="vcxt"
  />
</template>

<script>
import {getLayoutCmp} from '@/runtime/CmpStore'
import VJsonContext from "@/runtime/VJsonContext"
import YvI18nMixin from "@/components/YvI18nMixin";

export default {
  mixins: [YvI18nMixin],
  props: {
    vjson: Object,
    vcxt: VJsonContext
  },
  created() {
    this.vcxt.setSlots(this.$slots)
  },
  data() {
    return {
      vjsonReloadMark: false
    }
  },
  watch: {
    'vjson': {
      handler(newVal) {
        this.vjsonReloadMark = true
        this.$nextTick(() => {
          this.vjsonReloadMark = false
        })
      }
    }
  },
  methods: {
    getLayoutCmp
  }
}
</script>